//
//  FQDLabOpinionsCellItemProvider.m
//  FakeQDaily
//
//  Created by mewxiv on 9/16/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "FQDLabOpinionsCellItemProvider.h"
#import "FQDRestModel.h"
#import "QDailyAPI.h"

#import "YYModel.h"

static NSString *const kLabOpinionFeed = @"lab_opinions";

@interface FQDLabOpinionsCellItemProvider ()

@property (nonatomic, strong) NSArray *opinions;

@end

@implementation FQDLabOpinionsCellItemProvider

- (void)getCellItems:(NSString *)cursorKey completion:(QDailyAPICompleteBlock)completion
{
    [[QDailyAPI sharedAPI] getLabOptions:self.feedId key:cursorKey completion:completion];
}

- (void)parseResponse:(id)response isLatest:(BOOL)isLatest
{
    self.opinions = [NSArray yy_modelArrayWithClass:[FQDLabOpinion class]
                                               json:response[@"options"]];
}

- (void)populateNewCellItemsTo:(NSMutableArray *)originalCellItems
{
    for (FQDLabOpinion *opinion in self.opinions) {
        [originalCellItems addObject:opinion];
    }
}

- (NSString *)cacheId
{
    return kLabOpinionFeed;
}

@end
